import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MenuPanel extends JPanel implements ActionListener {
    private Icon bgSave = Util.getIcon("/images/buttonSave.jpg");
    private Icon bgGet = Util.getIcon("/images/buttonGet.jpg");
    private Icon bgFind = Util.getIcon("/images/buttonFind.jpg");
    private Icon bgOff = Util.getIcon("/images/buttonOff.jpg");
    private ATM frame;
    private JButton offButton = new JButton(bgOff);
    private JButton saveButton = new JButton(bgSave);
    private JButton getButton = new JButton(bgGet);
    private JButton findButton = new JButton(bgFind);

    public MenuPanel(ATM frame) {
        this.frame = frame;
        this.setLayout(null);
        this.setOpaque(false);
        saveButton.setBounds(300, 300, 100, 50);
        getButton.setBounds(300, 400, 100, 50);
        findButton.setBounds(300, 500, 100, 50);
        offButton.setBounds(300, 600, 100, 50);
        this.add(saveButton);
        this.add(getButton);
        this.add(findButton);
        this.add(offButton);
        saveButton.addActionListener(this);
        getButton.addActionListener(this);
        findButton.addActionListener(this);
        offButton.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (offButton == e.getSource()) {
            frame.switchPanel("login");
        }    else if (saveButton == e.getSource()) {
            frame.switchPanel("save");
        }  else if (getButton == e.getSource()) {
            frame.switchPanel("get");
        }else         if (findButton == e.getSource()) {
            frame.switchPanel("find");
        }
    }
}
